<template>
	<view>
		<view class="promoter-order">
			<view class='promoterHeader bg-color'>
				<view class='headerCon acea-row row-between-wrapper'>
					<view>
						<view class='name'>累积推广订单</view>
						<view><text class='num'>{{recordList.length}}</text>单</view>
					</view>
					<view class='iconfont icon-2'></view>
				</view>
			</view>
			<view class="nav acea-row row-around">
				<view class="timeFilter">
					<uni-datetime-picker v-model="datetimerange" type="daterange" mode="daterange" rangeSeparator="至"
						@change="handleConfirm">
						<view class="fold" @click="openPicker">自定义时间</view>
					</uni-datetime-picker>
				</view>
			</view>
			<view class='list pad30' v-if="recordList.length>0">
				<block v-for="(item,index) in recordList" :key="index">
					<view class='item'>
						<!-- <view class='title acea-row row-column row-center'>
							<view class='data'>{{item.time}}</view>
							<view>本月累计推广订单：{{item.count || 0}}单</view>
						</view> -->
						<view class='listn'>
							<view class='itenm borRadius14'>
								<view class='top acea-row row-between-wrapper'>
									<view class='pictxt acea-row row-between-wrapper'>
										<view class='pictrue'>
											<image :src='item.msqUser.avatar'></image>
										</view>
										<view class='text line1'>{{item.msqUser.nickname}}</view>
									</view>
									<view class='money'>业绩金额：<text class=''>￥{{item.dividendMoney}}</text></view>
									<!-- 	<view class='money' v-if="item.type == 'brokerage'">返佣：<text class='font-color'>￥{{item.number}}</text></view>
										<view class='money' v-else>暂未返佣：<text class='font-color'>￥{{item.number}}</text></view> -->
								</view>
								<view class='bottom'>
									<view class='leftName'><text style="color: #999;">订单编号：</text>{{item.orderNo}}
									</view>
									<!-- <view class='rightName'><text style="color: #999;">推荐奖：</text>{{item.number}}</view> -->
									<view class='leftName'><text style="color: #999;">下单时间：</text>{{item.createTime}}</view>
									<!-- <view class='rightName'><text style="color: #999;">见单奖：</text>{{item.number}}</view> -->
								</view>
							</view>
						</view>
					</view>
				</block>
			</view>
			<view v-if="recordList.length == 0">
				<emptyPage title="暂无推广订单～"></emptyPage>
			</view>
		</view>
		<!-- #ifdef MP -->
		<!-- #endif -->
		<home></home>
	</view>
</template>

<script>
	import {
		spreadOrder
	} from '@/api/user.js';
	import {
		getDetailedOrderList
	} from '@/api/xing.js';
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	// #ifdef MP
	import authorize from '@/components/Authorize';
	// #endif
	import emptyPage from '@/components/emptyPage.vue'
	import home from '@/components/home';
	export default {
		components: {
			// #ifdef MP
			authorize,
			// #endif
			emptyPage,
			home
		},
		data() {
			return {
				pageSize: 10,
				pageNum: 1,
				datetimerange: ['', ''], // 初始值为空数组
				status: false,
				recordList: [],
				recordCount: 0,
				isAuto: false, //没有授权的不会自动授权
				isShowAuth: false, //是否隐藏授权
			};
		},
		// computed: mapGetters(['isLogin']),
		// onLoad() {
		// 	if (this.isLogin) {
		// 		this.getRecordOrderList();
		// 	} else {
		// 		toLogin();
		// 	}
		// },
		mounted() {
			this.getRecordOrderList()
		},
		methods: {
			handleConfirm(e) {
				this.page = 1,
					this.limit = 10,
					this.getRecordOrderList()
				console.log('选择的日期范围:', this.beginDate, this.endDate);
			},
			openPicker() {
				// 触发日期选择器的显示
				this.$refs.datetimePicker.show();
			},
			getRecordOrderList: function() {
				let that = this;
				let pageSize = that.pageSize;
				let pageNum = that.pageNum;
				let status = that.status;
				let recordList = that.recordList;
				let newList = [];
				if (status == true) return;
				getDetailedOrderList({
					pageSize: pageSize,
					pageNum: pageNum,
					beginDate: that.datetimerange[0],
					endDate: that.datetimerange[1],
				}).then(res => {
					this.recordList = res.rows
					// let recordListData = res.rows ? res.rows : [];
					// console.log(recordListData.length, res.rows, "recordListData")
					// // 每页返回的总条数；
					// let len = 0;
					// for (let i = 0; i < recordListData.length; i++) {
					// 	len = len + recordListData[i].child.length;
					// 	let str = recordListData[i].time.replace(/-/g, '/');
					// 	let date = new Date(str).getTime();
					// 	if (that.time === date) {
					// 		that.$set(that.recordList[i], 'child', that.recordList[i].child.concat(
					// 			recordListData[i].child));
					// 	} else {
					// 		recordListData.forEach((item, index) => {
					// 			if (recordListData[i] == item) {
					// 				newList.push(item);
					// 			}
					// 		})
					// 		that.$set(that, 'recordList', recordList.concat(newList));
					// 	}
					// 	that.time = date;
					// };
					// that.recordCount = res.data.count || 0;
					// that.status = limit > len;
					that.pageNum = pageNum + 1;
				});
			}
		},
		onReachBottom() {
			this.getRecordOrderList()
		}
	}
</script>

<style scoped lang="scss">
	.headerCon {
		background-image: url('http://store-profit-system.oss-cn-shanghai.aliyuncs.com/uniappImg/commissionBackground.png');
		background-repeat: no-repeat;
		background-size: 100% 100%;
		width: 100%;
		height: 221rpx;
	}

	.promoter-order .list .item .title {
		height: 133rpx;
		font-size: 26rpx;
		color: #999;
	}

	.promoter-order .list .item .title .data {
		font-size: 28rpx;
		color: #282828;
		margin-bottom: 5rpx;
	}

	.promoter-order .list .item .listn .itenm {
		background-color: #fff;
		margin-top: 20rpx;
	}

	.promoter-order .list .item .listn .itenm~.itenm {
		margin-top: 20rpx;
	}

	.promoter-order .list .item .listn .itenm .top {
		padding: 0 24rpx;
		border-bottom: 1rpx solid #eee;
		height: 100rpx;
	}

	.promoter-order .list .item .listn .itenm .top .pictxt {
		width: 320rpx;
	}

	.promoter-order .list .item .listn .itenm .top .pictxt .text {
		width: 230rpx;
		font-size: 30rpx;
		color: #282828;
	}

	.promoter-order .list .item .listn .itenm .top .pictxt .pictrue {
		width: 66rpx;
		height: 66rpx;
	}

	.promoter-order .list .item .listn .itenm .top .pictxt .pictrue image {
		width: 100%;
		height: 100%;
		border-radius: 50%;
		border: 3rpx solid #fff;
		box-sizing: border-box;
		box-shadow: 0 0 15rpx #aaa;
	}

	.promoter-order .list .item .listn .itenm .top .money {
		font-size: 28rpx;
	}

	.promoter-order .list .item .listn .itenm .bottom {
		padding: 20rpx 24rpx;
		font-size: 28rpx;
		color: #666;
		line-height: 1.6;
		display: flex;
		justify-content: flex-start;
		flex-wrap: wrap;
	}

	.promoter-order .list .item .listn .itenm .bottom .leftName {
		width: 100%;
		height: 25rpx;
		font-weight: 400;
		font-size: 26rpx;
		color: #333;
		line-height: 25rpx;
		text-align: left;
		margin-top: 10rpx;

	}

	.promoter-order .list .item .listn .itenm .bottom .rightName {
		width: 40%;
		height: 25rpx;
		font-weight: 400;
		font-size: 26rpx;
		color: #333;
		line-height: 25rpx;
		text-align: right;
		margin-top: 10rpx;
	}

	.nav {
		background-color: #fff;
		height: 86rpx;
		line-height: 86rpx;
		font-size: 28rpx;
		color: #000;
		border-bottom: 1rpx solid #EEEEEE;
		border-top-left-radius: 14rpx;
		border-top-right-radius: 14rpx;
	}

	.fold {
		float: right;
		margin-right: -340rpx;
	}
</style>